package com.yhq.spring.event;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hqyin
 * @date 2023/3/14 12:15 下午
 */
@RestController
@Slf4j
public class TestController {
    @Autowired
    private EventByExtendsService eventByExtendsService;

    /**
     * 测试通过继承ApplicationEvent实现的事件
     * @param msgId
     * @return
     */
    @GetMapping("/eventByExtends/{msgId}")
    public String publishEventByExtends(@PathVariable String msgId){
        EventByExtends eventByExtends = new EventByExtends(msgId+"xxx");
        eventByExtendsService.publish(eventByExtends);
        return "success";
    }
}
